package com.senjoeson.teamfriends.utils;

import android.graphics.Bitmap;

import java.io.File;
import java.io.FileOutputStream;

/**
 * Created by senjoeson on 2018/5/11.
 */

public class ImageUtils {


    public static File bitmap2File(Bitmap bitmap, String fileName) {
        FileOutputStream fileOutStream = null;
        try {
            //通过相关方法生成一个Bitmap类型的对象

            File file = new File(FileUtils.getInstance().getImgFolderPath(), fileName);
            if (!file.exists()) {
                file.createNewFile();
            }
            fileOutStream = new FileOutputStream(file);
            bitmap.compress(Bitmap.CompressFormat.PNG, 100, fileOutStream); // 把位图输出到指定的文件中
            fileOutStream.flush();
            fileOutStream.close();
            return file;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;

    }
}
